<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算年龄案例</title>
    <script>
        var year = prompt('请输入您的出生年月');
        var age = 2020 - parseInt(year);//由于year是字符串，需要进行转换
        alert('您今年已经' + age + '岁了');
    </script>
</head>
<body>

</body>
</html>